﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace WindowsFormsApplication1.wtyczki
{
    class Transformation
    {
        public static Bitmap noisereductionType1 (Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm,1,1,1,1,1,1,1,1,1);
            return bmTemp;
        }
        public static Bitmap noisereductionType2(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 1, 1, 1, 1, 2, 1, 1, 1, 1);
            return bmTemp;
        }
        public static Bitmap noisereductionType3(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 1, 2, 1, 2, 4, 2, 1, 2, 1);
            return bmTemp;
        }
        public static Bitmap noisereductionType4(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 1, 1, 1, 1, 0, 1, 1, 1, 1);
            return bmTemp;
        }


        //EDGES
        public static Bitmap edgedetectionLaplasjan1(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 0, -1, 0, -1, 4, -1, 0, -1, 0);
            return bmTemp;
        }
        public static Bitmap edgedetectionLaplasjan2(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, -1, -1, -1, 8, -1, -1, -1, -1);
            return bmTemp;
        }
        public static Bitmap edgedetectionLaplasjan3(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, -2, -1, -2, 4, -2, -1, -2, -1);
            return bmTemp;
        }
        public static Bitmap edgedetectionLaplasjan4(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 0, -1, 0, -1, 5, -1, 0, -1, 0);
            return bmTemp;
        }
        public static Bitmap edgedetectionLaplasjan5(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, -1, -1, -1, 9, -1, -1, -1, -1);
            return bmTemp;
        }
        public static Bitmap edgedetectionLaplasjan6(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, -2, -1, -2, 5, -2, -1, -2, -1);
            return bmTemp;
        }

        //CORNERS
        public static Bitmap cornerdetectionUpperLeft(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, -1, 1, -1, -2, 1, 1, 1, 1);
            return bmTemp;
        }
        public static Bitmap cornerdetectionUpperRight(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 1, -1, -1, 1, -2, -1, 1, 1, 1);
            return bmTemp;
        }
        public static Bitmap cornerdetectionDownLeft(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 1, 1, 1, -1, -2, 1, -1, -1, 1);
            return bmTemp;
        }
        public static Bitmap cornerdetectionDownRight(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 1, 1, 1, 1, -2, -1, 1, -1, -1);
            return bmTemp;
        }
        //GRADIENTS
        public static Bitmap gradientRoberts45(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 0, 0, 0, -1, 0, 0, 0, 1, 0);
            return bmTemp;
        }
        public static Bitmap gradientRoberts135(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, 0, 0, 0, 0, 0, -1, 0, 1, 0);
            return bmTemp;
        }
        //PREWITT
        public static Bitmap prewittHorizontal(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, -1, -1, 0, 0, 0, 1, 1, 1);
            return bmTemp;
        }
        public static Bitmap prewittVertical(Bitmap bm)
        {
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, -1, 0, 1, -1, 0, 1, -1, 0, 1);
            return bmTemp;
        }
        public static Bitmap customMask(Bitmap bm)
        {
            List<int> lstValue= new List<int>();
            using (customMask forma = new customMask())
            {
                forma.ShowDialog();
                lstValue = forma.TheValue;
            }
            Bitmap bmTemp = wtyczki.basicMatrix.multiply(bm, lstValue[0], lstValue[1], lstValue[2],
                                                             lstValue[3], lstValue[4], lstValue[5],
                                                             lstValue[6], lstValue[7], lstValue[8]);
            return bmTemp;
        }
    }
}
